from django import template
from ..models import Resume, New_Likes, Work, Prize, Lab

register = template.Library()


@register.simple_tag
def get_resume_num():
    return Resume.objects.count()


@register.simple_tag
def get_work_list(resume_id):
    return Work.objects.filter(resume_id=resume_id)


@register.simple_tag
def get_prize_list(resume_id):
    return Prize.objects.filter(resume_id=resume_id)


@register.simple_tag
def get_lab_list(resume_id):
    return Lab.objects.filter(resume_id=resume_id)


@register.simple_tag
def get_like_number(user):
    resume_list = Resume.objects.filter(author=user)
    count = 0
    for resume in resume_list:
        count = +resume.total_like
    return count
